package com.eksframework.commons.core.validator.annotations;

import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;

/**
 * 时间格式验证
 *
 * @author chenfenghai
 */
@Documented
@Target({ElementType.PARAMETER, ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = TimeFormatValidator.class)
public @interface TimeFormat {

    /**
     * The custom pattern to use to format the field.
     * <p>Defaults to empty String, indicating no custom pattern String has been specified.
     * Set this attribute when you wish to format your field in accordance with a custom
     * date time pattern not represented by a style or ISO format.
     * <p>Note: This pattern follows the original {@link java.text.SimpleDateFormat} style,
     * as also supported by Joda-Time, with strict parsing semantics towards overflows
     * (e.g. rejecting a Feb 29 value for a non-leap-year). As a consequence, 'yy'
     * characters indicate a year in the traditional style, not a "year-of-era" as in the
     * {@link java.time.format.DateTimeFormatter} specification (i.e. 'yy' turns into 'uu'
     * when going through that {@code DateTimeFormatter} with strict resolution mode).
     */
    String pattern() default "HH:mm:ss";

    String message() default "时间不正确";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

}
